import java.util.*;
public class Test {
    public static int ret,count,n,m,len;
    public static boolean[][] vis;
    public static int[] dx = {1,-1,0,0};
    public static int[] dy = {0,0,1,-1};
    public static char[][] ch;
    public static Queue<int[]> q;
    public static void bfs(){
        while(!q.isEmpty()){
            int size = q.size();
            len++;
            for(int i = 0;i < size;i++){
                int[] t = q.poll();
                int a = t[0],b = t[1];
                for(int k = 0;k < 4;k++){
                    int x = dx[k] + a;
                    int y = dy[k] + b;
                    if(x >= 0 && x < n && y >= 0 && y < m && !vis[x][y] && ch[x][y] != '*'){
                        if(ch[x][y] == 'e'){
                            ret = Math.min(ret,len);
                        }else{
                            q.add(new int[]{x,y});
                        }
                        vis[x][y] = true;
                    }
                }
            }
        }

    }
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        ret = Integer.MAX_VALUE;len = 0;count = 0;
        vis = new boolean[n][m];
        ch = new char[n][m];
        q = new LinkedList<>();
        for(int i = 0;i < n;i++){
            ch[i] = in.next().toCharArray();
            for(int j = 0;j < m;j++){
                if(ch[i][j] == 'k'){
                    q.offer(new int[]{i,j});
                    vis[i][j] = true;
                }
            }
        }
        bfs();
        for(int i = 0;i < n;i++){
            for(int j = 0;j < m;j++){
                if(ch[i][j] == 'e' && vis[i][j])count++;
            }
        }
        if(count == 0)System.out.print(-1);
        else System.out.print(count + " " + ret);
    }
}